<?php 
class Gold_Ordereditem_ReportController extends Mage_Adminhtml_Controller_Action{

    public function indexAction(){
          $this->loadLayout()
            ->_addBreadcrumb(Mage::helper('ordereditem')->__('Reports'), Mage::helper('ordereditem')->__('Reports'))
            ->_addBreadcrumb(Mage::helper('ordereditem')->__('Ordereditem'), Mage::helper('ordereditem')->__('Ordereditem'));
        $report = $this->getLayout()->createBlock('ordereditem/report');
        $form = $this->getLayout()->createBlock('ordereditem/form');
        $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('filter'));
        $params = new Varien_Object();
        foreach ($requestData as $key => $value) {
            if (!empty($value)) {
                $params->setData($key, $value);
            }
        }
        $gridBlock = $this->getLayout()->getBlock('report.grid');
        $gridBlock->setFilterData($params);
        $form->setFilterData($params);
        $report->setChild('grid.filter.form',$form);
        $this->_addContent($report);
        $this->renderLayout();
    }
    public function itemsAction(){
        
        $this->loadLayout()
            ->_addBreadcrumb(Mage::helper('ordereditem')->__('Reports'), Mage::helper('ordereditem')->__('Reports'))
            ->_addBreadcrumb(Mage::helper('ordereditem')->__('Ordereditem'), Mage::helper('ordereditem')->__('Ordereditem'));
        $report = $this->getLayout()->createBlock('ordereditem/report');
        $form = $this->getLayout()->createBlock('ordereditem/form');
        $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('filter'));
        $params = new Varien_Object();
        foreach ($requestData as $key => $value) {
            if (!empty($value)) {
                $params->setData($key, $value);
            }
        }
        $params->setData('report','yes');
        $gridBlock = $this->getLayout()->getBlock('report.grid');
        $gridBlock->setFilterData($params);
        $form->setFilterData($params);
        $report->setChild('grid.filter.form',$form);
        $this->_addContent($report);
        $this->renderLayout();
    
    }
     /**
     * Export sales report grid to CSV format
     */
    public function exportItemsCsvAction()
    {
        $fileName   = 'tems.csv';
        $grid       = $this->getLayout()->createBlock('ordereditem/report_grid');
        $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('filter'));
        $params = new Varien_Object();
        foreach ($requestData as $key => $value) {
            if (!empty($value)) {
                $params->setData($key, $value);
            }
        }
        $params->setData('report','yes');
        $grid->setFilterData($params);
        $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
    }

}
